home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / OpenTransport / Interfaces / PInterfaces / OpenTptAppleTalk.p next >
Encoding:
Text File  |  1996-11-21  |  11.1 KB  |  332 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        OpenTptAppleTalk.p
  3.  
  4.      Contains:    Public AppleTalk definitions
  5.  
  6.      Copyright:    © 1984-1996 by Apple Computer, Inc.
  7.                  All rights reserved.
  8.  
  9. }
  10. {$IFC UNDEFINED UsingIncludes}
  11. {$SETC UsingIncludes := 0}
  12. {$ENDC}
  13.  
  14. {$IFC NOT UsingIncludes}
  15.  UNIT OpenTptAppleTalk;
  16.  INTERFACE
  17. {$ENDC}
  18.  
  19. {$IFC UNDEFINED __OPENTPTAPPLETALK__}
  20. {$SETC __OPENTPTAPPLETALK__ := 1}
  21.  
  22. {$I+}
  23. {$SETC OpenTptAppleTalkIncludes := UsingIncludes}
  24. {$SETC UsingIncludes := 1}
  25.  
  26. {$IFC UNDEFINED __OPENTRANSPORT__}
  27. {$I OpenTransport.p}
  28. {$ENDC}
  29.  
  30. {$PUSH}
  31. {$ALIGN MAC68K}
  32. {$LibExport+}
  33.  
  34. {
  35. ******************************************************************************
  36. ** Module definitions
  37. *******************************************************************************
  38. }
  39. {  XTI Levels }
  40.  
  41. CONST
  42.     ATK_DDP                        = 'DDP ';
  43.     ATK_AARP                    = 'AARP';
  44.     ATK_ATP                        = 'ATP ';
  45.     ATK_ADSP                    = 'ADSP';
  46.     ATK_ASP                        = 'ASP ';
  47.     ATK_PAP                        = 'PAP ';
  48.     ATK_NBP                        = 'NBP ';
  49.     ATK_ZIP                        = 'ZIP ';
  50.  
  51. {  Module Names }
  52.  
  53.     kDDPName        = 'ddp';
  54.     kATPName        = 'atp';
  55.     kADSPName        = 'adsp';
  56.     kASPName        = 'asp';
  57.     kPAPName        = 'pap';
  58.     kNBPName        = 'nbp';
  59.     kZIPName        = 'zip';
  60.     kLTalkName        = 'ltlk';
  61.     kLTalkAName        = 'ltlkA';
  62.     kLTalkBName        = 'ltlkB';
  63.  
  64. {
  65. ******************************************************************************
  66. ** Protocol-specific Options
  67. **
  68. ** NOTE:
  69. ** All Protocols support OPT_CHECKSUM (Value is (unsigned long)T_YES/T_NO)
  70. ** ATP supports OPT_RETRYCNT (# Retries, 0 = try once) and
  71. **                OPT_INTERVAL (# Milliseconds to wait)
  72. *******************************************************************************
  73. }
  74.     DDP_OPT_CHECKSUM            = $0600;                        {  DDP UnitDataReq Only - set src address     }
  75.     DDP_OPT_SRCADDR                = $2101;                        {  Value is DDPAddress                         }
  76.                                                                 {  AppleTalk - ATP Resp Pkt Ct Type             }
  77.     ATP_OPT_REPLYCNT            = $2110;                        {  Value is (unsigned long)  pkt count         }
  78.                                                                 {  AppleTalk - ATP Pkt Data Len Type         }
  79.     ATP_OPT_DATALEN                = $2111;                        {  Value is (unsigned long) length             }
  80.                                                                 {  AppleTalk - ATP Release Timer Type         }
  81.                                                                 {  Value is (unsigned long) timer             }
  82.     ATP_OPT_RELTIMER            = $2112;                        {  (See Inside AppleTalk, second edition     }
  83.     ATP_OPT_TRANID                = $2113;                        {  Value is (unsigned long) Boolean             }
  84.                                                                 {  AppleTalk - PAP OpenConn Retry count         }
  85.     PAP_OPT_OPENRETRY            = $2120;                        {  Value is (unsigned long) T_YES/T_NO         }
  86.  
  87. {
  88. ******************************************************************************
  89. ** Protocol-specific events
  90. *******************************************************************************
  91. }
  92.     kAppleTalkEvent                = $23010000;
  93.  
  94. {
  95.  * If you send the IOCTL: OTIoctl(I_OTGetMiscellaneousEvents, 1),
  96.  * you will receive these events on your endpoint.
  97.  * NOTE: The endpoint does not need to be bound.
  98.  *
  99.  * No routers have been seen for a while.  If the cookie is NULL,
  100.  * all routers are gone.  Otherwise, there is still an ARA router
  101.  * hanging around being used, and only the local cable has been 
  102.  * timed out.
  103. }
  104.     T_ATALKROUTERDOWNEVENT        = $23010033;
  105.     kAllATalkRoutersDown        = 0;
  106.     kLocalATalkRoutersDown        = -1;
  107.     kARARouterDisconnected        = -2;
  108.     T_ATALKROUTERUPEVENT        = $23010034;
  109.     kARARouterOnline            = -1;
  110.     kATalkRouterOnline            = 0;
  111.     kLocalATalkRouterOnline        = -2;
  112.     T_ATALKZONENAMECHANGEDEVENT    = $23010035;
  113.     T_ATALKCONNECTIVITYCHANGEDEVENT = $23010036;
  114.     T_ATALKINTERNETAVAILABLEEVENT = $23010037;
  115.     T_ATALKCABLERANGECHANGEDEVENT = $23010038;
  116.  
  117. {
  118. ******************************************************************************
  119. ** Protocol-specific IOCTLs
  120. *******************************************************************************
  121. }
  122.  
  123.     ATALK_IOC_FULLSELFSEND        = $5430;
  124.     ADSP_IOC_FORWARDRESET        = $543C;
  125. {
  126. ******************************************************************************
  127. ** Protocol-specific constants
  128. *******************************************************************************
  129. }
  130. {
  131.     -------------------------------------------------------------------------
  132.         ECHO
  133.         ------------------------------------------------------------------------- 
  134. }
  135.     kECHO_TSDU                    = 585;                            {  Max. # of data bytes. }
  136.  
  137. {
  138.     -------------------------------------------------------------------------
  139.         NBP
  140.         ------------------------------------------------------------------------- 
  141. }
  142.     kNBPMaxNameLength            = 32;
  143.     kNBPMaxTypeLength            = 32;
  144.     kNBPMaxZoneLength            = 32;
  145.     kNBPSlushLength                = 9;                            {  Extra space for @, : and a few escape chars }
  146.     kNBPMaxEntityLength            = 99;
  147.     kNBPEntityBufferSize        = 105;
  148.     kNBPWildCard                = $3D;                            {  NBP name and type match anything '=' }
  149.     kNBPImbeddedWildCard        = $C5;                            {  NBP name and type match some '≈' }
  150.     kNBPDefaultZone                = $2A;                            {  NBP default zone '*' }
  151.  
  152. {
  153.     -------------------------------------------------------------------------
  154.         ZIP
  155.         ------------------------------------------------------------------------- 
  156. }
  157.     kZIPMaxZoneLength            = 32;
  158.  
  159. {
  160.     -------------------------------------------------------------------------
  161.         Address-related values
  162.         ------------------------------------------------------------------------- 
  163. }
  164.     kDDPAddressLength            = 8;                            {  value to use in netbuf.len field }
  165.                                                                 {  Maximum length of AppleTalk address }
  166.     kNBPAddressLength            = 105;
  167.     kAppleTalkAddressLength        = 113;
  168.  
  169. {
  170. ******************************************************************************
  171. ** CLASS TAppleTalkServices
  172. *******************************************************************************
  173. }
  174. {$IFC NOT OTKERNEL }
  175. {$IFC UNDEFINED __cplusplus }
  176.  
  177. TYPE
  178.     ATSvcRef                            = Ptr;
  179. {$ELSEC}
  180.  
  181. TYPE
  182.     TAppleTalkServicesPtr = ^TAppleTalkServices;
  183.     TAppleTalkServices = RECORD
  184.     END;
  185.  
  186.     ATSvcRef                            = ^TAppleTalkServices;
  187. {$ENDC}
  188.  
  189. CONST
  190.     kDefaultAppleTalkServicesPath = -3;
  191.  
  192. FUNCTION OTAsyncOpenAppleTalkServices(VAR cfig: OTConfiguration; flags: OTOpenFlags; notifyProc: OTNotifyProcPtr; contextPtr: UNIV Ptr): OSStatus;
  193. FUNCTION OTOpenAppleTalkServices(VAR cfig: OTConfiguration; flags: OTOpenFlags; VAR err: OSStatus): ATSvcRef;
  194. {  Get the zone associated with the ATSvcRef }
  195. FUNCTION OTATalkGetMyZone(ref: ATSvcRef; VAR zone: TNetbuf): OSStatus;
  196. {
  197.  Get the list of available zones associated with the local cable
  198.  of the ATSvcRef
  199. }
  200. FUNCTION OTATalkGetLocalZones(ref: ATSvcRef; VAR zones: TNetbuf): OSStatus;
  201. {  Get the list of all zones on the internet specified by the ATSvcRef }
  202. FUNCTION OTATalkGetZoneList(ref: ATSvcRef; VAR zones: TNetbuf): OSStatus;
  203. {  Stores an AppleTalkInfo structure into the TNetbuf (see later in this file) }
  204. FUNCTION OTATalkGetInfo(ref: ATSvcRef; VAR info: TNetbuf): OSStatus;
  205. {$ENDC}
  206. {
  207.     -------------------------------------------------------------------------
  208.     AppleTalk Addressing
  209.     
  210.     The NBPEntity structure is used to manipulate NBP names without regard
  211.     to issues of what kind of "special" characters are in the name.
  212.     
  213.     When stored as an address in an NBPAddress or DDPNBPAddress, they are 
  214.     stored as a character string, which is currently just ASCII, but in the
  215.     future may be UniChar, or some other internationalizable scripting set.
  216.     The string following an NBPAddress or DDPNBPAddress is intended to be
  217.     suitable for showing to users, whereas NBPEntity is not.
  218.     WARNING: NBPAddress and DDPNBPAddress structures do not "know" the length
  219.     of the address.  That must have been obtained as part of a Lookup or
  220.     ResolveAddress call.
  221.     ------------------------------------------------------------------------- 
  222. }
  223.  
  224. TYPE
  225.     DDPAddressPtr = ^DDPAddress;
  226.     DDPAddress = RECORD
  227.         fAddressType:            OTAddressType;
  228.         fNetwork:                UInt16;
  229.         fNodeID:                SInt8;
  230.         fSocket:                SInt8;
  231.         fDDPType:                SInt8;
  232.         fPad:                    SInt8;
  233.     END;
  234.  
  235.     NBPAddressPtr = ^NBPAddress;
  236.     NBPAddress = RECORD
  237.         fAddressType:            OTAddressType;
  238.         fNBPNameBuffer:            PACKED ARRAY [0..104] OF UInt8;
  239.     END;
  240.  
  241.     DDPNBPAddressPtr = ^DDPNBPAddress;
  242.     DDPNBPAddress = RECORD
  243.         fAddressType:            OTAddressType;
  244.         fNetwork:                UInt16;
  245.         fNodeID:                SInt8;
  246.         fSocket:                SInt8;
  247.         fDDPType:                SInt8;
  248.         fPad:                    SInt8;
  249.         fNBPNameBuffer:            PACKED ARRAY [0..104] OF UInt8;
  250.     END;
  251.  
  252.     NBPEntityPtr = ^NBPEntity;
  253.     NBPEntity = RECORD
  254.         fEntity:                PACKED ARRAY [0..98] OF UInt8;
  255.     END;
  256.  
  257. {
  258.     ---------------------------------------------------------------------
  259.         These are some utility routines for dealing with NBP and DDP addresses. 
  260.         --------------------------------------------------------------------- 
  261. }
  262. {  Functions to initialize the various AppleTalk Address types }
  263. PROCEDURE OTInitDDPAddress(VAR addr: DDPAddress; net: UInt16; node: ByteParameter; socket: ByteParameter; ddpType: ByteParameter);
  264. FUNCTION OTInitNBPAddress(VAR addr: NBPAddress; name: ConstCStringPtr): size_t;
  265. FUNCTION OTInitDDPNBPAddress(VAR addr: DDPNBPAddress; name: ConstCStringPtr; net: UInt16; node: ByteParameter; socket: ByteParameter; ddpType: ByteParameter): size_t;
  266. {  Compare 2 DDP addresses for equality }
  267. FUNCTION OTCompareDDPAddresses({CONST}VAR addr1: DDPAddress; {CONST}VAR addr2: DDPAddress): BOOLEAN;
  268. {  Init an NBPEntity to a NULL name }
  269. PROCEDURE OTInitNBPEntity(VAR entity: NBPEntity);
  270. {
  271.  Get the length an NBPEntity would have when stored as an address
  272.  
  273. }
  274. FUNCTION OTGetNBPEntityLengthAsAddress({CONST}VAR entity: NBPEntity): size_t;
  275. {  Store an NBPEntity into an address buffer }
  276. FUNCTION OTSetAddressFromNBPEntity(VAR nameBuf: UInt8; {CONST}VAR entity: NBPEntity): size_t;
  277. {  Create an address buffer from a string (use -1 for len to use strlen) }
  278. FUNCTION OTSetAddressFromNBPString(VAR addrBuf: UInt8; name: ConstCStringPtr; len: SInt32): size_t;
  279. {
  280.  Create an NBPEntity from an address buffer. False is returned if
  281.    the address was truncated.
  282. }
  283. FUNCTION OTSetNBPEntityFromAddress(VAR entity: NBPEntity; {CONST}VAR addrBuf: UInt8; len: size_t): BOOLEAN;
  284. {  Routines to set a piece of an NBP entity from a character string }
  285. FUNCTION OTSetNBPName(VAR entity: NBPEntity; name: ConstCStringPtr): BOOLEAN;
  286. FUNCTION OTSetNBPType(VAR entity: NBPEntity; typeVal: ConstCStringPtr): BOOLEAN;
  287. FUNCTION OTSetNBPZone(VAR entity: NBPEntity; zone: ConstCStringPtr): BOOLEAN;
  288. {  Routines to extract pieces of an NBP entity }
  289. PROCEDURE OTExtractNBPName({CONST}VAR entity: NBPEntity; name: CStringPtr);
  290. PROCEDURE OTExtractNBPType({CONST}VAR entity: NBPEntity; typeVal: CStringPtr);
  291. PROCEDURE OTExtractNBPZone({CONST}VAR entity: NBPEntity; zone: CStringPtr);
  292.  
  293. CONST
  294.     AF_ATALK_FAMILY                = $0100;
  295.     AF_ATALK_DDP                = $0100;
  296.     AF_ATALK_DDPNBP                = $0101;
  297.     AF_ATALK_NBP                = $0102;
  298.     AF_ATALK_MNODE                = $0103;
  299.  
  300. {
  301.     -------------------------------------------------------------------------
  302.         AppleTalkInfo - filled out by the OTGetATalkInfo function
  303.     ------------------------------------------------------------------------- 
  304. }
  305.  
  306. TYPE
  307.     AppleTalkInfoPtr = ^AppleTalkInfo;
  308.     AppleTalkInfo = RECORD
  309.         fOurAddress:            DDPAddress;                                {  Our DDP address (network # & node) }
  310.         fRouterAddress:            DDPAddress;                                {  The address of a router on our cable }
  311.         fCableRange:            ARRAY [0..1] OF UInt16;                    {  The current cable range }
  312.         fFlags:                    UInt16;                                    {  See below }
  313.     END;
  314.  
  315. {  For the fFlags field in AppleTalkInfo }
  316.  
  317. CONST
  318.     kATalkInfoIsExtended        = $0001;                        {  This is an extended (phase 2) network }
  319.     kATalkInfoHasRouter            = $0002;                        {  This cable has a router }
  320.     kATalkInfoOneZone            = $0004;                        {  This cable has only one zone }
  321.  
  322. {$ALIGN RESET}
  323. {$POP}
  324.  
  325. {$SETC UsingIncludes := OpenTptAppleTalkIncludes}
  326.  
  327. {$ENDC} {__OPENTPTAPPLETALK__}
  328.  
  329. {$IFC NOT UsingIncludes}
  330.  END.
  331. {$ENDC}
  332.